from genesis.gen.engine.utils import station_configuration
from genesis.gen.engine.utils import sequence_definition
from genesis.gen.engine.utils import constant
from genesis.gen.engine.utils import exception
from genesis.gen.engine.utils import utility
from genesis.gen.engine.utils import locking
from genesis.gen.engine.utils import sync


PASS = "_passed"
SKIP = "_skipped"
FAIL = "_failed"
JUMP = "_jumped"

conn = constant.CONN

userdict = constant.userdict


def FailureException(msg):
    return exception.FailureException(msg)


def AbortException(msg):
    return exception.AbortException(msg)


def get_seq_logger():
    return constant.SEQ_LOGGER


def get_container_name():
    return constant.CONTAINER_NAME


def generate_test_report(report=True):
    constant.REPORT = report
    return


def get_container_status(name):
    return utility.get_container_status(name)


def get_sync_group(group_name):
    return utility.get_sync_group(group_name)


def get_test_step_name():
    return utility.get_test_step_name()


def get_operator_name():
    return utility.get_operator_name()


def set_operator_name(name):
    return utility.set_operator_name(name)


def get_configuration_data():
    return utility.get_configuration_data()


def get_genesis_configuration():
    return station_configuration.GenesisConfiguration()


def get_sequence_definition(name):
    return sequence_definition.SequenceDefinition(name)


def set_display1(display):
    return utility.set_display1(display)


def set_display2(display):
    return utility.set_display2(display)


def set_display3(display):
    return utility.set_display3(display)


def update_test_time():
    return utility.update_test_time()


def ask_question(question, timeout=7200, answers=None, image=None, visible=True, privilege=False, multiple=False):
    return utility.ask_question(
        question,
        timeout=timeout,
        answers=answers,
        image=image,
        visible1=visible,
        privilege=privilege,
        multiple1=multiple
    )


def acquire_locking(name, wait_timeout=3600, privilege=False):
    locking.acquire_locking(name, wait_timeout=wait_timeout, privilege=privilege)


def release_locking(name):
    locking.release_locking(name)


class FIFOLocking(locking.FIFOLocking):
    def __init__(self, name, wait_timeout=3600, privilege=False):
        super(FIFOLocking, self).__init__(name, wait_timeout=wait_timeout, privilege=privilege)


def fifo_locking(name, wait_timeout=3600, privilege=False):
    return locking.fifo_locking(name, wait_timeout=wait_timeout, privilege=privilege)


def clean_sync_up(group_name):
    return sync.clean_sync_up(group_name)


def sync_up(group_name, wait_timeout=3600):
    return sync.sync_up(group_name, wait_timeout=wait_timeout)


class SyncUp(sync.SyncUp):
    def __init__(self, group_name, wait_timeout=3600):
        super(SyncUp, self).__init__(group_name, wait_timeout=wait_timeout)


def leader_sync_up(group_name, leader_container, wait_timeout=3600):
    return sync.leader_sync_up(group_name, leader_container=leader_container, wait_timeout=wait_timeout)


def get_test_log_path():
    return utility.get_test_log_path()


def set_test_name(name):
    return utility.set_test_name(name)


def start_container_test(name, override=True):
    return utility.start_container_test(name, override=override)


def put_cache_data(key, value):
    return utility.put_cache_data(key, value)


def get_cache_data(key):
    return utility.get_cache_data(key)


def add_test_data(sernum, uuttype, area, container, **kwargs):
    return utility.add_test_data(sernum, uuttype, area, container, **kwargs)


def set_container_color(color=None):
    return utility.set_container_color(color=color)
